package com.test.springai.controller;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 8/20/25 8:58 AM
 * @modifiedBy:
 * @version: 1.0
 */
@RestController
public class RagController {
  @Autowired private ChatClient chatClient;
  @Autowired private VectorStore vectorStore;

  @GetMapping("/rag")
  public String rag(String input) {
    return chatClient
        .prompt()
        .user(input)
        .advisors(new QuestionAnswerAdvisor(vectorStore))
        .call()
        .content();
  }
}
